<?php

namespace app\modules\api\controllers;

use Yii;
use yii\rest\ActiveController;

/**
 * @OA\Tag(
 *   name="Role",
 *   description="角色管理",
 * )
 */
class RoleController extends ActiveController
{
    public $modelClass = 'app\modules\api\models\Role';

    /**
     * @OA\Get(
     *      path="/role",
     *      summary="角色列表",
     *      tags={"Role"},
     *      @OA\Parameter(
     *          description="页数",
     *          in="query",
     *          name="page",
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Parameter(
     *          description="每页数量",
     *          in="query",
     *          name="pageSize",
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功",
     *          @OA\MediaType(
     *              mediaType="application/json",
     *              @OA\Schema(
     *                  @OA\Property(
     *                      property="role",
     *                      type="array",
     *                      @OA\Items(
     *                          @OA\Property(property="id", type="integer", example="1", description="角色ID"),
     *                          @OA\Property(property="name", type="string", example="文员", description="角色名称"),
     *                          @OA\Property(property="status", type="integer", example="1", description="状态"),
     *                          @OA\Property(property="remark", type="string", example="xxx", description="备注"),
     *                          @OA\Property(property="author", type="string", example="admin", description="创建人"),
     *                          @OA\Property(property="createdAt", type="integer", example="2020-06-22 10:39:47", description="创建时间"),
     *                      ),
     *                  ),
     *                  @OA\Property(property="totalCount", type="integer", example="30", description="角色总数"),
     *                  @OA\Property(property="pageSize", type="integer", example="15", description="每页数量"),
     *                  @OA\Property(property="page", type="integer", example="2", description="总页数")
     *              )
     *          )
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionIndex()
    {
    }

    /**
     * @OA\Post(
     *      path="/role/create",
     *      tags={"Role"},
     *      summary="添加角色",
     *      @OA\RequestBody(
     *          @OA\MediaType(
     *              mediaType="multipart/form-data",
     *              @OA\Schema(
     *                  required={"name"},
     *                  @OA\Property(property="name", type="string", description="角色名称"),
     *                  @OA\Property(property="remark", type="string", description="备注", default=""),
     *                  @OA\Property(property="setDefault", type="boolean", description="设置为默认权限", default="false"),
     *                  @OA\Property(
     *                      property="item[]",
     *                      type="array",
     *                      description="权限项",
     *                      @OA\Items(type="integer")
     *                  ),
     *                  @OA\Property(
     *                      property="auth[]",
     *                      type="array",
     *                      description="权限项对应的数据授权类型",
     *                      @OA\Items(type="integer")
     *                  ),
     *                  @OA\Property(
     *                      property="data[]",
     *                      type="array",
     *                      description="权限项对应的自定义数据授权的值",
     *                      @OA\Items(type="integer")
     *                  ),
     *             )
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionCreate()
    {
    }

    /**
     * @OA\Post(
     *      path="/role/update",
     *      tags={"Role"},
     *      summary="编辑角色",
     *      @OA\Parameter(
     *          name="id",
     *          in="query",
     *          description="角色ID",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *          ),
     *      ),
     *      @OA\RequestBody(
     *          @OA\MediaType(
     *              mediaType="multipart/form-data",
     *              @OA\Schema(
     *                  required={"name"},
     *                  @OA\Property(property="name", type="string", description="角色名称"),
     *                  @OA\Property(property="remark", type="string", description="备注", default=""),
     *                  @OA\Property(property="setDefault", type="boolean", description="设置为默认权限", default="false"),
     *                  @OA\Property(
     *                      property="item[]",
     *                      type="array",
     *                      description="权限项",
     *                      @OA\Items(type="integer")
     *                  ),
     *                  @OA\Property(
     *                      property="auth[]",
     *                      type="array",
     *                      description="权限项对应的数据授权类型",
     *                      @OA\Items(type="integer")
     *                  ),
     *                  @OA\Property(
     *                      property="data[]",
     *                      type="array",
     *                      description="权限项对应的自定义数据授权的值",
     *                      @OA\Items(type="integer")
     *                  ),
     *             )
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionUpdate()
    {
    }

    /**
     * @OA\Post(
     *      path="/role/delete",
     *      summary="删除角色",
     *      tags={"Role"},
     *      @OA\Parameter(
     *          description="角色ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionDelete()
    {
    }

    /**
     * @OA\Post(
     *      path="/role/enable",
     *      summary="启用角色",
     *      tags={"Role"},
     *      @OA\Parameter(
     *          description="角色ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionEnable()
    {

    }

    /**
     * @OA\Post(
     *      path="/role/disable",
     *      summary="禁用角色",
     *      tags={"Role"},
     *      @OA\Parameter(
     *          description="角色ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionDisable()
    {

    }

    /**
     * @OA\Get(
     *      path="/role/get-item-data",
     *      summary="获取某角色下某个权限项的自定部门授权数据",
     *      tags={"Role"},
     *      @OA\Parameter(
     *          description="角色ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Parameter(
     *          description="权限项ID",
     *          in="query",
     *          name="itemId",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功",
     *          @OA\MediaType(
     *              mediaType="application/json",
     *              @OA\Schema(
     *                  @OA\Property(
     *                      property="group",
     *                      type="array",
     *                      @OA\Items(
     *                          type="object",
     *                          @OA\Property(property="id", type="integer", example=1, description="组织ID"),
     *                          @OA\Property(property="label", type="string", example="晟田集团", description="组织名称"),
     *                          @OA\Property(property="count", type="integer", example=2000, description="组织下的人数统计"),
     *                          @OA\Property(
     *                              property="children",
     *                              type="array",
     *                              @OA\Items(
     *                                  type="object",
     *                                  @OA\Property(property="id", type="integer", example=1, description="部门ID"),
     *                                  @OA\Property(property="pid", type="integer", example=0, description="部门上级ID"),
     *                                  @OA\Property(property="label", type="string", example="IT部门", description="部门名称"),
     *                                  @OA\Property(property="count", type="integer", example=3, description="部门下的人数统计"),
     *                                  @OA\Property(property="checked", type="boolean", example="true", description="是否选中（ true：是、false：否 ）"),
     *                                  @OA\Property(
     *                                      property="children",
     *                                      type="array",
     *                                      @OA\Items(
     *                                          @OA\Property(property="id", type="integer", example=2, description="部门ID"),
     *                                          @OA\Property(property="pid", type="integer", example=1, description="部门上级ID"),
     *                                          @OA\Property(property="label", type="string", example="技术开发部", description="部门名称"),
     *                                          @OA\Property(property="count", type="integer", example=3, description="部门下的人数统计"),
     *                                          @OA\Property(property="checked", type="boolean", example="true", description="是否选中（ true：是、false：否 ）"),
     *                                          @OA\Property(
     *                                             property="children",
     *                                             type="array",
     *                                             @OA\Items()
     *                                          )
     *                                      )
     *                                  )
     *                              )
     *                          )
     *                      )
     *                  )
     *              )
     *          )
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionGetItemData()
    {

    }

    /**
     * @OA\Get(
     *      path="/role/get-info",
     *      summary="获取角色基本信息用于编辑",
     *      tags={"Role"},
     *      @OA\Parameter(
     *          description="角色ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功",
     *          @OA\MediaType(
     *              mediaType="application/json",
     *              @OA\Schema(
     *                  @OA\Property(
     *                      property="role",
     *                      type="object",
     *                      @OA\Property(property="id", type="integer", example="1", description="id"),
     *                      @OA\Property(property="name", type="string", example="文员", description="角色名称"),
     *                      @OA\Property(property="remark", type="string", example="xx", description="备注"),
     *                  ),
     *                  @OA\Property(
     *                      property="item",
     *                      type="array",
     *                      @OA\Items(
     *                          type="object",
     *                          @OA\Property(property="id", type="integer", example=1, description="权限项ID"),
     *                          @OA\Property(property="pid", type="integer", example=0, description="上级ID"),
     *                          @OA\Property(property="name", type="string", example="客户管理", description="权限项名称"),
     *                          @OA\Property(property="auth", type="integer", example=1, description="是否需要数据权限（ 0：否、1：是 、2：字段权限）"),
     *                          @OA\Property(property="type", type="integer", example=0, description="数据权限类型（0：不需要、其它见 typeList）"),
     *                          @OA\Property(property="checked", type="boolean", example=true, description="选中（ true：是、false：否 ）"),
     *                          @OA\Property(property="status", type="integer", example=0, description="状态（ 0：禁用、1：启用 ）"),
     *                          @OA\Property(
     *                              property="children",
     *                              type="array",
     *                              @OA\Items(
     *                                  type="object",
     *                                  @OA\Property(property="id", type="integer", example=1, description="权限项ID"),
     *                                  @OA\Property(property="pid", type="integer", example=0, description="上级ID"),
     *                                  @OA\Property(property="name", type="string", example="客户", description="权限项名称"),
     *                                  @OA\Property(property="auth", type="integer", example=1, description="是否需要数据权限（ 0：否、1：是 、2：字段权限）"),
     *                                  @OA\Property(property="type", type="integer", example=0, description="数据权限类型（0：不需要、其它见 typeList）"),
     *                                  @OA\Property(property="checked", type="boolean", example=true, description="选中（ true：是、false：否 ）"),
     *                                  @OA\Property(property="status", type="integer", example=0, description="状态（ 0：禁用、1：启用 ）"),
     *                                  @OA\Property(
     *                                      property="children",
     *                                      type="array",
     *                                          @OA\Items(
     *                                          @OA\Property(property="id", type="integer", example=1, description="权限项ID"),
     *                                          @OA\Property(property="pid", type="integer", example=0, description="上级ID"),
     *                                          @OA\Property(property="name", type="string", example="列表", description="权限项名称"),
     *                                          @OA\Property(property="auth", type="integer", example=1, description="是否需要数据权限（ 0：否、1：是 、2：字段权限）"),
     *                                          @OA\Property(property="type", type="integer", example=0, description="数据权限类型（0：不需要、其它见 typeList）"),
     *                                          @OA\Property(property="checked", type="boolean", example=true, description="选中（ true：是、false：否 ）"),
     *                                          @OA\Property(property="status", type="integer", example=0, description="状态（ 0：禁用、1：启用 ）"),
     *                                          @OA\Property(
     *                                             property="children",
     *                                             type="array",
     *                                             @OA\Items()
     *                                          )
     *                                      )
     *                                  )
     *                              )
     *                          )
     *                      )
     *                  ),
     *
     *
     *              )
     *          )
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionGetInfo()
    {

    }

    /**
     * @OA\Get(
     *      path="/role/get-default-item",
     *      summary="获取角色的默认权限项",
     *      tags={"Role"},
     *      @OA\Parameter(
     *          description="角色ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功",
     *          @OA\MediaType(
     *              mediaType="application/json",
     *              @OA\Schema(
     *                  @OA\Property(
     *                      property="item",
     *                      type="array",
     *                      @OA\Items(
     *                          type="object",
     *                          @OA\Property(property="id", type="integer", example=1, description="权限项ID"),
     *                          @OA\Property(property="pid", type="integer", example=0, description="上级ID"),
     *                          @OA\Property(property="name", type="string", example="客户管理", description="权限项名称"),
     *                          @OA\Property(property="auth", type="integer", example=1, enum={0, 1, 2}, description="是否需要数据权限（ 0：不需要、1：需要 、2：字段权限）"),
     *                          @OA\Property(property="type", type="integer", example=0, enum={1, 2, 3, 4}, description="数据权限类型（ 1：读写、2：只读、3：只读密文、4：不可见 ）"),
     *                          @OA\Property(property="checked", type="boolean", example=true, description="选中（ true：是、false：否 ）"),
     *                          @OA\Property(property="status", type="integer", example=0, description="状态（ 0：禁用、1：启用 ）"),
     *                          @OA\Property(
     *                              property="children",
     *                              type="array",
     *                              @OA\Items(
     *                                  type="object",
     *                                  @OA\Property(property="id", type="integer", example=1, description="权限项ID"),
     *                                  @OA\Property(property="pid", type="integer", example=0, description="上级ID"),
     *                                  @OA\Property(property="name", type="string", example="客户", description="权限项名称"),
     *                                  @OA\Property(property="auth", type="integer", example=1, enum={0, 1, 2}, description="是否需要数据权限（ 0：不需要、1：需要 、2：字段权限）"),
     *                                  @OA\Property(property="type", type="integer", example=0, enum={1, 2, 3, 4}, description="数据权限类型（ 1：读写、2：只读、3：只读密文、4：不可见 ）"),
     *                                  @OA\Property(property="checked", type="boolean", example=true, description="选中（ true：是、false：否 ）"),
     *                                  @OA\Property(property="status", type="integer", example=0, description="状态（ 0：禁用、1：启用 ）"),
     *                                  @OA\Property(
     *                                      property="children",
     *                                      type="array",
     *                                          @OA\Items(
     *                                          @OA\Property(property="id", type="integer", example=1, description="权限项ID"),
     *                                          @OA\Property(property="pid", type="integer", example=0, description="上级ID"),
     *                                          @OA\Property(property="name", type="string", example="列表", description="权限项名称"),
     *                                          @OA\Property(property="auth", type="integer", example=1, enum={0, 1, 2}, description="是否需要数据权限（ 0：不需要、1：需要 、2：字段权限）"),
     *                                          @OA\Property(property="type", type="integer", example=0, enum={1, 2, 3, 4}, description="数据权限类型（ 1：读写、2：只读、3：只读密文、4：不可见 ）"),
     *                                          @OA\Property(property="checked", type="boolean", example=true, description="选中（ true：是、false：否 ）"),
     *                                          @OA\Property(property="status", type="integer", example=0, description="状态（ 0：禁用、1：启用 ）"),
     *                                          @OA\Property(
     *                                             property="children",
     *                                             type="array",
     *                                             @OA\Items()
     *                                          )
     *                                      )
     *                                  )
     *                              )
     *                          )
     *                      )
     *                  ),
     *              )
     *          )
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionGetDefaultItem()
    {

    }
}
